package rooms.southPod;

import actions.Direction;
import items.armor.Freak;
import rooms.Room;
import mobs.NPC;
import mobs.DaveWilliams;
import exceptions.MudExceptions;
import items.Item;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class CeoOffice implements Room {

    private static Room me;

    private List<NPC> mobs = new ArrayList<NPC>();
    private List<Item> items = new ArrayList<Item>();
    private Random r = new Random();

    public static synchronized Room getInstance() {
        if (me == null) {
            me = new CeoOffice();
        }
        return me;
    }

    public CeoOffice() {

        if (r.nextInt(10) < 7) {        
            mobs.add(new DaveWilliams());
        }
        items.add(new Freak());
    }

    public String getTitle() {
        return "Ceo's Office";
    }

    public String getDescription() {
        return "This is where the big boss lives.  Tread lightly";
    }

    public String getLongDescription() {
        return "This room is overwhelmingly orange.  The only offsetting color is some chrome.  It is bright " +
                "and seemingly welcoming.  The chairs are all orange, and don't look very comfortable.";
    }

    @Override
    public Room getRoomMove(Direction direction) {
        Room room;
        if (direction == Direction.EAST) {
            room = WestHallway1.getInstance();
        } else if (direction == Direction.DOWN) {
            throw MudExceptions.invalidMoveDown();
        } else if (direction == Direction.UP) {
            throw MudExceptions.invalidMoveUp();
        } else {
            throw MudExceptions.invalidMove();
        }
        return room;
    }
    
    public List<NPC> getActiveNPCs() {
        return mobs;
    }

    public String showMobs() {
        StringBuffer rtn = new StringBuffer();
        for (NPC npc : getActiveNPCs()) {
            rtn.append(npc.getName());
            rtn.append("\n");
        }
        return rtn.toString();
    }

    public List<Item> getRoomItems() {
        return items;
    }

    public String showItems() {
        StringBuffer rtn = new StringBuffer();
        for (Item item : getRoomItems()) {
            rtn.append(item.getTitle());
            rtn.append("\n");
        }
        return rtn.toString();
    }
}
